package com.sgl.retrofitdemo;

import android.app.Application;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
import com.sgl.retrofitdemo.utils.RetrofitSystemUtils;

/**
 * Created by sunqiyong on 2016/11/13.
 */

public class RetrofitApplication extends Application {
    private static final String TAG = "RETROFIT";

    private static RetrofitApplication app;

    /**
     * 屏幕高
     */
    public static int SCREEN_H = 0;
    /**
     * 屏幕宽
     */
    public static int SCREEN_W = 0;
    /**
     * 屏幕密度
     */
    public static float DENSITY = 0.0f;

    public static String UDID = "";

    public static RetrofitApplication getInstance() {
        return app;
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //MultiDex.install(this);
        //GreenDaoCore.initUseApplicationContext(this);
        //GreenDaoCore.enableQueryBuilderLog(BuildConfig.DEBUG);

        DisplayMetrics dm = new DisplayMetrics();
        WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(dm);
        SCREEN_W = dm.widthPixels;
        SCREEN_H = dm.heightPixels;
        DENSITY = dm.density;
        if (SCREEN_W > SCREEN_H) {
            int i = SCREEN_H;
            SCREEN_H = SCREEN_W;
            SCREEN_W = i;
        }

    }

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        UDID = RetrofitSystemUtils.getUdId(getApplicationContext());
        Logger.init(TAG).methodOffset(2).logLevel(LogLevel.FULL); // release
        //FrescoUtils.init(this, 100);
        //SDKConstant.getInstance(app);
        RetrofitSystemUtils.getSystemLanguage(app);
    }

    public static RetrofitApplication getApplication() {
        return app;
    }
}
